package com.hzsai.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Description 下划线转驼峰
 * @Author suzhenyin
 * @Date 2019/4/23 10:58
 * @Version 1.0
 **/
public class LineToHumpUtils {

    private static Pattern linePattern = Pattern.compile("_(\\w)");

    public static String lineToHump(String str) {
        str = str.toLowerCase();
        Matcher matcher = linePattern.matcher(str);
        StringBuffer sb = new StringBuffer();
        while (matcher.find()) {
            matcher.appendReplacement(sb, matcher.group(1).toUpperCase());
        }
        matcher.appendTail(sb);
        return sb.toString();
    }

}